package cn.hiapi.shopkeeper.jpa.order;

import cn.hiapi.basic.jpa.BasicRepository;
import cn.hiapi.shopkeeper.entity.order.ActivityInviteRecord;
import org.springframework.data.jpa.repository.Query;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author AdinZ
 * @date 2023/1/10 10:20
 */
public interface ActivityInviteRecordJpa extends BasicRepository<ActivityInviteRecord,Long> {


    @Query("select sum(e.shareAmount) from ActivityInviteRecord e where e.inviteUid=?1 and e.aid=?2 and e.status=1")
    BigDecimal totalShareAmount(long inviteUid, long aid);

    @Query("select count(e.id) from ActivityInviteRecord e where e.inviteUid=?1 and e.aid=?2 and e.created between ?3 and ?4 and e.newGift=0 group by e.uid")
    List<Object> todayInviteCount(long inviteUid, long aid, long start, long end);
}
